package edu.qqilin.springframework.beans.factory.support;

import edu.qqilin.springframework.beans.factory.config.SingletonBeanRegistry;

import java.util.HashMap;
import java.util.Map;

/**
 * Description: 单例注册表的默认实现。
 * <p>
 * 内部维护了 Map<String, Object> singletonObjects（一级缓存），用于存放造好的单例对象。
 *
 * @author qqilin1213
 * @version 1.0
 * @date 2025/11/22 16:11
 */
public class DefaultSingletonBeanRegistry implements SingletonBeanRegistry {
    private Map<String, Object> singletonObjects = new HashMap<>();

    @Override
    public Object getSingleton(String beanName) {
        return singletonObjects.get(beanName);
    }

    protected void addSingleton(String beanName, Object singletonObject){
        singletonObjects.put(beanName,singletonObject);
    }
}
